/*
 * @Descripttion: ob-decrypt
 * @Version: 1.0
 * @Author: undead
 * @Date: 2022-01-12 16:31:59
 * @LastEditors: undead
 * @LastEditTime: 2022-02-08 12:14:17
 */

module.exports = {
  name: "ob-decrypt",
  checkFeature: function (nodes) {
    const firstNode = nodes.program.body.shift();
    if (firstNode.body.type !== "FunctionDeclaration" && firstNode.body.type !== "BlockStatement") return false;

    const bodyNode = firstNode.body.body;
    const featName = firstNode.id.name;
    const initNode = bodyNode[0].declarations[0].init;
    if(initNode.type !== "ArrayExpression") return false;
    const keys = initNode.elements.map(x=> x.value);
    console.log(keys);
    return bodyNode.at(-1).type === "ReturnStatement" && bodyNode.at(-1).argument.callee.name === featName;
  },
  init: function (nodes) {
    return nodes;
  },
};
